/*
 * CopyRight(C) Kenbin
 */

#include "lws_postag.h"

LWS::CPosTag::CPosTag(CHmm *hmm) : m_hmmalgo(hmm)
{
}

void LWS::CPosTag::PosTag(vector<int> &best_wordids)
{
    int total_observe = m_hmmalgo.TotalObserve();
    vector<int> observes;
    observes.resize(best_wordids.size());
    for(unsigned i = 0; i < best_wordids.size(); i ++) {
	switch(best_wordids[i]) {
	    case NUMBER:
		observes[i] = total_observe - 5;
		break;
	    case TIME:
		observes[i] = total_observe - 4;
		break;
	    case PERSON:
		observes[i] = total_observe - 3;
		break;
	    case LOCATION:
		observes[i] = total_observe - 2;
		break;
	    case UNKNOWN:
		observes[i] = total_observe - 1;
		break;
	    default:
		observes[i] = best_wordids[i];
		break;
	}
    }

    m_best_states.resize(0);
    m_hmmalgo.GetBestStateSequence(observes, m_best_states);
}
